/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package conf.redis;

/**
 *
 * @author dell
 */
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
public class Text 
{
public static void element(NodeList list)
{
     for(int i=0;i<list.getLength();i++)
     {
         Element element=(Element)list.item(i);
         NodeList childNodes=element.getChildNodes();
         for(int j=0;j<childNodes.getLength();j++)
         {
             if(childNodes.item(j).getNodeType()==Node.ELEMENT_NODE)
             {
                 System.out.print(childNodes.item(j).getNodeName()+":");
                 System.out.println(childNodes.item(j).getFirstChild().getNodeValue());
             }
         }
     }
}
public static void node(NodeList list)
{
     for(int i=0;i<list.getLength();i++)
     {
         Node node=list.item(i);
         NodeList childNodes=node.getChildNodes();
         for(int j=0;j<childNodes.getLength();j++)
         {
             if(childNodes.item(j).getNodeType()==Node.ELEMENT_NODE)
             {
                 System.out.print(childNodes.item(j).getNodeName());
                 System.out.print(childNodes.item(j).getFirstChild().getNodeValue());
                 System.out.println();
             }
         }
     }
}
public static void main(String[] asd)
{
     DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
     try
     {
         DocumentBuilder builder=factory.newDocumentBuilder();
         Document d=builder.parse("src/java/conf/redis/mredispool-conf.xml");
         NodeList sList=d.getElementsByTagName("configuration");
         node(sList);
     }
     catch(Exception e)
     {
         e.printStackTrace();
     }
}
}
